{extend name='main'}

{block name="content"}

<div class="think-box-shadow">
    <fieldset>
        <legend>条件搜索</legend>
        <form class="layui-form layui-form-pane form-search" action="{:request()->url()}" onsubmit="return false"
              method="get" autocomplete="off">
            <!--
            {if auth("do_deposit") }
            <div class="layui-form-item layui-inline" style="margin-right: 10px">
                <button data-action='{:url("do_deposit2")}' data-csrf="{:systoken('do_deposit2')}" data-rule="id#{key}"
                        class='layui-btn layui-btn-sm layui-btn-danger'>批量通过
                </button>
                <button data-action='{:url("do_deposit3")}' data-csrf="{:systoken('do_deposit3')}" data-rule="id#{key}"
                        class='layui-btn layui-btn-sm layui-btn-warning'>批量拒绝
                </button>
            </div>
            {/if}
            -->
            <div class="layui-form-item layui-inline">
                <label class="layui-form-label">代理审核</label>
                <div class="layui-input-inline">
                    <select name="agent_status">
                        <option value="">全部</option>
                        <option value="1" {if $agent_status==1} selected{/if}>未审核</option>
                        <option value="2" {if $agent_status==2} selected{/if}>已通过</option>
                        <option value="3" {if $agent_status==3} selected{/if}>已驳回</option>
                    </select>
                </div>
            </div>
            <div class="layui-form-item layui-inline">
                <label class="layui-form-label">状态</label>
                <div class="layui-input-inline">
                    <select name="status">
                        <option value="">全部</option>
                        <option value="1" {if $status==1} selected{/if}>未审核</option>
                        <option value="2" {if $status==2} selected{/if}>已通过</option>
                        <option value="3" {if $status==3} selected{/if}>已驳回</option>
                        <option value="4" {if $status==4} selected{/if}>转账失败</option>
                    </select>
                </div>
            </div>
            <div class="layui-form-item layui-inline">
                <label class="layui-form-label">一级代理</label>
                <div class="layui-input-inline">
                    <select name="agent_id">
                        <option value="0">全部</option>
                        {foreach $agent_list as $k=>$v}
                        <option value="{$k}"{if $agent_id==$k} selected{/if}>{$v}</option>
                        {/foreach}
                    </select>
                </div>
            </div>
            <div class="layui-form-item layui-inline">
                <label class="layui-form-label">二级代理</label>
                <div class="layui-input-inline">
                    <select name="agent_service_id">
                        <option value="0">全部</option>
                        {foreach $agent_service_list as $k=>$v}
                        <option value="{$k}"{if $agent_service_id==$k} selected{/if}>{$v}</option>
                        {/foreach}
                    </select>
                </div>
            </div>

            <div class="layui-form-item layui-inline">
                <label class="layui-form-label">订单号</label>
                <div class="layui-input-inline">
                    <input name="oid" value="{$Think.get.oid|default=''}" placeholder="请输入订单号" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item layui-inline">
                <label class="layui-form-label">用户名称</label>
                <div class="layui-input-inline">
                    <input name="username" value="{$Think.get.username|default=''}" placeholder="请输入用户名称"
                           class="layui-input">
                </div>
            </div>
            <div class="layui-form-item layui-inline">
                <label class="layui-form-label">手机号</label>
                <div class="layui-input-inline">
                    <input name="mobile" value="{$Think.get.mobile|default=''}" placeholder="请输入用户手机号"
                           class="layui-input">
                </div>
            </div>
            <div class="layui-form-item layui-inline">
                <label class="layui-form-label">发起时间</label>
                <div class="layui-input-inline">
                    <input data-date-range name="addtime" value="{$Think.get.addtime|default=''}" placeholder="请选择发起时间"
                           class="layui-input">
                </div>
            </div>
            <div class="layui-form-item layui-inline">
                <button class="layui-btn layui-btn-primary"><i class="layui-icon">&#xe615;</i> 搜 索</button>
                {if auth("daochu") }
                <a href="{:url('daochu')}" class="layui-btn layui-btn-danger"><i class="layui-icon">&#xe615;</i>
                    导 出</a>
                {/if}
            </div>
        </form>
    </fieldset>
    <fieldset>当前付款方式：{$payout_type}</fieldset>
    <script>form.render()</script>
    <table class="layui-table margin-top-15" lay-skin="line">
        {notempty name='list'}
        <thead>
        <tr>
            <th class='list-table-check-td think-checkbox'>
                <input data-auto-none data-check-target='.list-check-box' type='checkbox'>
            </th>
            <th class='text-left nowrap' title="订单号/提现方式/代理">订单号/提现方式/代理</th>
            <th class='text-left nowrap' title="用户/手机/级别/余额">用户信息</th>
            <th class='text-left nowrap' title="用户/手机/级别/余额">一级代理/二级代理</th>
            <th class='text-left nowrap' title="提现金额/手续费/实际到账">提现金额</th>
            <th class='text-left nowrap' title="银行名称/开户名称/卡号/分行号/类型">银行信息/usdt</th>
            <th class='text-left nowrap'>电子钱包</th>
            <th class='text-left nowrap'>发起/处理/回调</th>
            <th class='text-left nowrap'>审核状态</th>
            <th class='text-left nowrap'>代理审核</th>
            <th class='text-left nowrap'>三方状态</th>
            {if auth('do_deposit')}
            <th class='text-left nowrap'>操作</th>
            {/if}
        </tr>
        </thead>
        {/notempty}
        <tbody>
        {foreach $list as $key=>$vo}
        <tr>
            <td class='list-table-check-td think-checkbox'>
                <input class="list-check-box" value='{$vo.id}' type='checkbox'>
            </td>
            <td class='text-left nowrap'>
                {$vo.id}<br>
                {$vo.w_type}<br>
            </td>
            <td class='text-left nowrap'>
                {$vo.username}<br>
                {$vo.u_tel}<br>
                VIP{$vo.level}<br>
                {:config("currency")}{$vo.balance}
            </td>
            <td>
                {$agent_list[$vo.agent_id]|default='---'}
                <br>
                {$agent_service_list[$vo.agent_service_id]|default='---'}
            </td>
            <td class='text-left nowrap'>
                {:config("currency")}{$vo.num}
                {if $vo.w_type=='USDT'}(U: {$vo.num2}){/if}
                <br>
                {$vo.shouxu*100}%<br>
                {:config("currency")}{$vo.real_num}
            </td>
            <td class='text-left nowrap'>
                {if $vo.w_type=='USDT'}
                {$vo.usdt}
                {else}
                {$vo.bankname}<br>
                {$vo.khname}<br>
                {$vo.cardnum}<br>
                <!-- -{$vo.account_digit}<br>
                {$vo.bank_branch}<br>
                {$vo.bank_type}<br>-->
                {$vo.document_type}&nbsp;&nbsp;{$vo.document_id}
                {/if}
            </td>
            <td class='text-left nowrap'>
                {$vo.tel}<br>
                {$vo.wallet_document_type}&nbsp;&nbsp;{$vo.wallet_document_id}<br>
                {$vo.wallet_tel}
            </td>
            <td class='text-left nowrap'>
                {$vo.addtime|format_datetime}<br>
                {$vo.endtime|format_datetime|default="-"}<br>
                {$vo.payout_time|format_datetime|default="-"}
            </td>
            <td class='text-left nowrap'>
                {switch $vo.status}
                {case 1}待审核{/case}
                {case 2}<a class="layui-btn layui-btn-xs">审核通过</a>{/case}
                {case 3}<a class="layui-btn layui-btn-xs layui-btn-danger">审核驳回</a>{/case}
                {case 4}转账失败{/case}
                {/switch}
            </td>
            <td class='text-left nowrap'>
                {switch $vo.agent_status}
                {case 1}待审核{/case}
                {case 2}<a class="layui-btn layui-btn-xs">审核通过</a>{/case}
                {case 3}<a class="layui-btn layui-btn-xs layui-btn-danger">审核驳回</a>{/case}
                {case 4}转账失败{/case}
                {/switch}
            </td>
            <td class='text-left'>
                {switch $vo.payout_status}
                {case 0}未提交{/case}
                {case 1}<a class="layui-btn layui-btn-xs layui-btn-primary">已提交</a>{/case}
                {case 2}<a class="layui-btn layui-btn-xs">转账成功</a>{/case}
                {case 3}<a class="layui-btn layui-btn-xs layui-btn-danger">转账失败</a>{/case}
                {/switch}
                <br>
                {$vo.payout_err_msg}
            </td>
            <td class='text-left nowrap'>
                {if ($vo.status == 1) and auth("do_deposit")}
                    {if $agent_id>0 && $vo.agent_status>1 }

                    {else}
                    <a class="layui-btn layui-btn-xs deposit_apply"
                       data-confirm="确定通过此提现记录吗?"
                       data-csrf="{:systoken('do_deposit')}"
                       data-action="{:url('do_deposit')}"
                       data-value="id#{$vo.id};status#2">通过</a>
                    <a class="layui-btn layui-btn-xs layui-btn-warm"
                       data-prompt="请输入驳回内容"
                       data-csrf="{:systoken('do_deposit')}"
                       data-action="{:url('do_deposit')}"
                       data-value="id#{$vo.id};status#3;uid#{$vo.uid};num#{$vo.num}">驳回</a>
                    {if $agent_id==0}
                    <a class="layui-btn layui-btn-xs layui-btn-danger deposit_demo_apply"
                       data-confirm="确定假设通过吗?此操作不会提交到第三方"
                       data-csrf="{:systoken('do_deposit')}"
                       data-action="{:url('do_deposit')}"
                       data-value="id#{$vo.id};status#88">假通过</a>
                    {/if}
                    {/if}
                {/if}

                {if $vo.status>1}{$vo.payout_type}{/if}
            </td>
        </tr>
        {/foreach}
        </tbody>
    </table>

    {empty name='list'}<span class="notdata">没有记录哦</span>{else}{$pagehtml|raw|default=''}{/empty}
    <script>
        var payType = '{$payout_type}';
        $('.deposit_apply').click(function () {
            var data = {
                "id": $(this).attr('data-id'),
                "status": 2,
                "payout_type": payType,
                "_csrf_": $(this).attr('data-csrf'),
            };
            layer.confirm('确定对该比订单付款吗？', {
                btn: [payType, '取消'], //可以无限个按钮
            }, function (index, layero) {
                depositListApply(data);
            }, function (index) {
                depositListApply(data);
            });
        });

        function depositListApply(data) {
            var lIndex = layer.load(2);
            $.ajax({
                type: 'POST',
                url: "{:url('do_deposit')}",
                data: data,
                success: function (res) {
                    layer.close(lIndex);
                    layer.alert(res.info, function (index) {
                        if (res.code == 1) location.reload();
                        layer.close(index);
                    });
                }
            });
        }
    </script>
</div>
{/block}
